'''
@author: pnuzhnyi
'''

from facebook import get_user_from_cookie
from settings import FACEBOOK_APP_ID, FACEBOOK_APP_SECRET

def is_authenticated(request):
    if request.get_host() == "fantasy-surf.appspot.com":
        cookie = get_user_from_cookie(request.COOKIES,FACEBOOK_APP_ID, FACEBOOK_APP_SECRET)
        if cookie: return True
        else: return False
    return True

def get_user_id(request):
    if request.get_host() == "fantasy-surf.appspot.com":
        cookie = get_user_from_cookie(request.COOKIES,FACEBOOK_APP_ID, FACEBOOK_APP_SECRET)
        if cookie: return cookie["uid"]
        else: return None
    return "user-id"